/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tuitionmanagement.components;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.border.BevelBorder;

/**
 *
 * @author PhucAn
 */
public class ToolKitButton extends JLabel {

   public  static int BTN_CLOSE = 1;
   public  static int BTN_RESTORE = 2;
   public  static int BTN_MIN = 3;
    int selMode = 0;
boolean mousein=false;
    public ToolKitButton(int BUTTON_MODE) {
        this.setPreferredSize(new Dimension(12, 12));
        // this.setBackground(Color.red);
        this.setVisible(true);
       
        selMode = BUTTON_MODE;
        this.addMouseListener(new MouseListener() {

            public void mouseClicked(MouseEvent e) {
               
            }

            public void mousePressed(MouseEvent e) {
                
            }

            public void mouseReleased(MouseEvent e) {
                
            }

            public void mouseEntered(MouseEvent e) {
                mousein=true;
               paintBorder();
            }

            public void mouseExited(MouseEvent e) {
             mousein=false;
             clearBorder();
            }
        });
    }

    @Override
    public void paint(Graphics g) {
       Graphics2D g2=(Graphics2D)g;
       if(!mousein){
        g2.setStroke(new BasicStroke(1));
       
        g2.setColor(Color.gray);
       }
       else
       {g2.setStroke(new BasicStroke(2));
          g2.setColor(Color.black);
       }
        
        
        if (selMode == BTN_CLOSE) {
            g.drawLine(0, 0, 8, 8);
            g.drawLine(8,0, 0, 8);
        }
        else if(selMode==BTN_MIN){
        g.drawLine(0, 8, 8,8);
        }else if(selMode==BTN_RESTORE){
        g.drawRect(0, 0, 8, 8);
        }
    }
    public void paintBorder(){
    this.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    }
    public void clearBorder(){
    this.setBorder(null);
    }
}
